package cn.pms.po;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * Department entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_department", schema = "SCOTT")
public class Department implements java.io.Serializable
{
	private static final long serialVersionUID = -8107145031005246545L;
	// Fields
	private Integer id;
	private String name;
	private Set<Check> checks = new HashSet<Check>(0);
	private Set<Employee> employees = new HashSet<Employee>(0);
	private Set<Message> messages = new HashSet<Message>(0);
	
	// Constructors
	/** default constructor */
	public Department()
	{}
	
	/** minimal constructor */
	public Department(String name)
	{
		this.name = name;
	}
	
	/** full constructor */
	public Department(String name, Set<Check> checks, Set<Employee> employees,
			Set<Message> messages)
	{
		this.name = name;
		this.checks = checks;
		this.employees = employees;
		this.messages = messages;
	}
	
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false, precision = 32, scale = 0)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DEP")
	@SequenceGenerator(name = "SEQ_DEP", sequenceName = "SEQ_DEP",allocationSize=0)
	public Integer getId()
	{
		return this.id;
	}
	
	public void setId(Integer id)
	{
		this.id = id;
	}
	
	@Column(name = "name", nullable = false, length = 100)
	public String getName()
	{
		return this.name;
	}
	
	public void setName(String name)
	{
		this.name = name;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department")
	public Set<Check> getChecks()
	{
		return this.checks;
	}
	
	public void setChecks(Set<Check> checks)
	{
		this.checks = checks;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department")
	public Set<Employee> getEmployees()
	{
		return this.employees;
	}
	
	public void setEmployees(Set<Employee> employees)
	{
		this.employees = employees;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department")
	public Set<Message> getMessages()
	{
		return this.messages;
	}
	
	public void setMessages(Set<Message> messages)
	{
		this.messages = messages;
	}
}
